import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Layout.vue'

Vue.use(VueRouter)

// 解决Vue-Router升级导致的Uncaught(in promise) navigation guard问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) {
    return originalPush.call(this, location, onResolve, onReject)
  }
  return originalPush.call(this, location).catch((err) => err)
}

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'opening',
      name: '页面开发中',
      component: () => import('../views/Opening')
    }, {
      path: 'home',
      name: '首页',
      component: () => import('../views/pages/Home/Home')
    }, {
      path: 'digitization',
      name: '数字化档案管理',
      component: () => import('../views/pages/Digitization/Digitization')
    }, {
      path: 'statistics/dataStatistics',
      name: '数据统计',
      component: () => import('../views/pages/Statistics/DataStatistics')
    }, {
      path: 'statistics/bigStatistics',
      name: '大图统计',
      component: () => import('../views/pages/Statistics/BigStatistics')
    }, {
      path: 'statistics/utilizeStatistics',
      name: '利用统计',
      component: () => import('../views/pages/Statistics/UtilizeStatistics')
    }, {
      path: 'statistics/warehouseStatistics',
      name: '库房统计',
      component: () => import('../views/pages/Statistics/WarehouseStatistics')
    }, {
      path: 'archivesManage/electronicsFile',
      name: '电子文件',
      component: () => import('../views/pages/ArchivesManage/ElectronicsFile')
    }, {
      path: 'archivesManage/electronicsArchives',
      name: '电子档案',
      component: () => import('../views/pages/ArchivesManage/ElectronicsArchives')
    }, {
      path: 'editStudy/memorabilia',
      name: '大事记',
      component: () => import('../views/pages/EditStudy/Memorabilia')
    }, {
      path: 'editStudy/organization',
      name: '组织机构沿革',
      component: () => import('../views/pages/EditStudy/Organization')
    }, {
      path: 'editStudy/qzIntroduce',
      name: '全宗介绍',
      component: () => import('../views/pages/EditStudy/QzIntroduce')
    }, {
      path: 'editStudy/typicalUtilizationEffect',
      name: '典型利用效果',
      component: () => import('../views/pages/EditStudy/TypicalUtilizationEffect')
    }, {
      path: 'archivalAppraisal/decrypt',
      name: '解密鉴定',
      component: () => import('../views/pages/ArchivalAppraisal/Decrypt')
    }, {
      path: 'archivalAppraisal/destruction',
      name: '销毁鉴定',
      component: () => import('../views/pages/ArchivalAppraisal/Destruction')
    }, {
      path: 'archivalAppraisal/OpenAppraisal',
      name: '开放鉴定',
      component: () => import('../views/pages/ArchivalAppraisal/OpenAppraisal')
    }, {
      path: 'utilize/utilizeQuery',
      name: '利用查询',
      component: () => import('../views/pages/Utilize/UtilizeQuery'),
      meta: {
        keepAlive: true
      }
    }, {
      path: 'utilize/utilizeQuery/utilizeDetails',
      name: '查看原文',
      component: () => import('../views/pages/Utilize/UtilizeDetails/UtilizeDetails')
    }, {
      path: 'utilize/utilizeRegister',
      name: '利用登记',
      component: () => import('../views/pages/Utilize/UtilizeRegister')
    }, {
      path: 'utilize/utilizeArchivesList',
      name: '利用列表',
      component: () => import('../views/pages/Utilize/UtilizeArchivesList'),
      meta: {
        keepAlive: true
      }
    }, {
      path: 'dataManage/DataImport',
      name: '数据导入',
      component: () => import('../views/pages/DataManage/DataImport'),
      children: [{
        path: '/',
        name: '数据导入',
        component: () => import('../views/pages/DataManage/DataImportIndex')
      }, {
        path: 'creatImport',
        name: '数据导入',
        component: () => import('../views/pages/DataManage/subordinatePage/creatImport')
      }]
    }, {
      path: 'dataManage/dataExport',
      name: '数据导出',
      component: () => import('../views/pages/DataManage/DataExport')
    }, {
      path: 'warehouseArchives',
      name: '库房档案管理',
      component: () => import('../views/pages/WarehouseManage/WarehouseArchives/index'),
      children: [{
        path: 'warehouseWithin',
        name: '库房内密级架',
        component: () => import('../views/pages/WarehouseManage/WarehouseArchives/childrenPage/WarehouseWithin')
      }, {
        path: 'shelfInside',
        name: '密级架内情况',
        component: () => import('../views/pages/WarehouseManage/WarehouseArchives/childrenPage/ShelfInside')
      }, {
        path: 'upperArchives',
        name: '上架的档案',
        component: () => import('../views/pages/WarehouseManage/WarehouseArchives/childrenPage/UpperArchives')
      }, {
        path: 'readOriginalText',
        name: '上架的档案',
        component: () => import('../views/pages/WarehouseManage/WarehouseArchives/childrenPage/ReadOriginalText')
      }]
    }, {
      path: 'warehouseIn',
      name: '库房入库',
      component: () => import('../views/pages/WarehouseManage/WarehouseIn/index')
    }, {
      path: 'warehouseManage',
      name: '温湿度管理',
      component: () => import('../views/pages/WarehouseManage/TemperatureHumidity/index')
    }, {
      path: 'paperBorrowing',
      name: '纸质档案借阅',
      component: () => import('../views/pages/WarehouseManage/PaperBorrowing/index')
    }, {
      path: 'systemSettings',
      name: '系统设置',
      component: () => import('../views/pages/SystemSettings/SystemSettings'),
      children: [{
        path: 'testItemManage',
        name: '检测项管理',
        component: () => import('../views/pages/SystemSettings/Settings/TestItemManage')
      }, {
        path: 'transferReceiveSet',
        name: '移交接收设置',
        component: () => import('../views/pages/SystemSettings/Settings/TransferReceiveSet')
      }, {
        path: 'metadataTest',
        name: '元数据项检测',
        component: () => import('../views/pages/SystemSettings/Settings/MetadataTest')
      }, {
        path: 'categoryTest',
        name: '门类项检测',
        component: () => import('../views/pages/SystemSettings/Settings/CategoryTest')
      }, {
        path: 'quanzong',
        name: '全宗设置',
        component: () => import('../views/pages/SystemSettings/Settings/Quanzong')
      }, {
        path: 'department',
        name: '部门设置',
        component: () => import('../views/pages/SystemSettings/Settings/Department')
      }, {
        path: 'menuSet',
        name: '菜单设置',
        component: () => import('../views/pages/SystemSettings/Settings/MenuSet')
      }, {
        path: 'user',
        name: '用户设置',
        component: () => import('../views/pages/SystemSettings/Settings/User')
      }, {
        path: 'role',
        name: '角色管理',
        component: () => import('../views/pages/SystemSettings/Settings/Role')
      }, {
        path: 'category',
        name: '门类设置',
        component: () => import('../views/pages/SystemSettings/Settings/Category'),
        children: [{
          path: 'categoryDetails',
          name: '门类设置查看',
          component: () => import('../views/pages/SystemSettings/Settings/CategoryDetails')
        }]
      }, {
        path: 'archivesCategory',
        name: '档案门类显示',
        component: () => import('../views/pages/SystemSettings/Settings/ArchivesCategory')
      }, {
        path: 'metadata',
        name: '元数据管理',
        component: () => import('../views/pages/SystemSettings/Settings/Metadata')
      }, {
        path: 'reference',
        name: '档号设置',
        component: () => import('../views/pages/SystemSettings/Settings/Reference')
      }, {
        path: 'auxiliary',
        name: '辅助鉴定表',
        component: () => import('../views/pages/SystemSettings/Settings/Auxiliary')
      }, {
        path: 'utilizationControl',
        name: '利用控制表',
        component: () => import('../views/pages/SystemSettings/Settings/UtilizationControl')
      }, {
        path: 'classification',
        name: '分类大纲',
        component: () => import('../views/pages/SystemSettings/Settings/Classification')
      }, {
        path: 'storagePeriod',
        name: '保管期限表',
        component: () => import('../views/pages/SystemSettings/Settings/StoragePeriod')
      }, {
        path: 'dataDictionary',
        name: '数据字典',
        component: () => import('../views/pages/SystemSettings/Settings/DataDictionary')
      }, {
        path: 'fileStore',
        name: '文件存储管理',
        component: () => import('../views/pages/SystemSettings/Settings/FileStore')
      }, {
        path: 'logAudit',
        name: '日志审计',
        component: () => import('../views/pages/SystemSettings/Settings/LogAudit')
      }, {
        path: 'userInfo',
        name: '个人信息',
        component: () => import('../views/pages/SystemSettings/Settings/UserInfo')
      }]
    }]
  },
  {
    path: '/login',
    name: '登录页',
    component: () => import('../views/login/Login'),
    meta: {
      keepAlive: true,
      isTab: false,
      isAuth: false
    }
  },
  {
    path: '*',
    name: 'NotFound',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import('../views/NotFound.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router
